********************************************************************************
****************            Table A12                              **************
********************************************************************************
use "C:\Users\junok\Dropbox\replication files\data sets\QSW_Undervaluation_Models_2022Nov23",clear
*use "C:\Users\quinnd\Dropbox\XR Politics\replication files\data sets\QSW_Undervaluation_Models_2022Nov23"

cd "C:\Users\junok\Dropbox\replication files\IO_Replication_July2023_JK\Part 3 Replication - July 2023"


********************************************************************************
drop if banking_center==1
drop if country=="Iraq"
drop if country=="El Salvador"
drop if country=="Mozambique"
drop if country=="Iran"
drop if country=="Syria" 
drop if country=="Lebanon"
drop if country=="Zimbabwe"
drop if wbcode=="BMU"
drop if wbcode=="VCT"
drop if wbcode=="LBR"

********************************************************************************
label var country "Country"
label var years "Year"
label var underval "Exchange Rate Undervaluation (Mean)"
label var wbcode "World Bank Country Code"
label var predict "Predict"
label var predict7089 "Predict"
label var predict9017 "Predict"
label var predict91 "Predict"
label var underval91 "Exchange Rate Unvervaluation_91"
label var lgrow9 "Log Growth"
label var balance9 "Trade/GDP Trade Balance"
label var popgr9 "Population Growth (mean)"
label var trade_gdp "Trade/GDP"
label var d1_d5 "Ratio between 1st Decile and 5th Decile"
label var ln_infl "Log Inflation (mean)"
label var inflation "Inflation (mean)"
label var inflation_gdpdeflator "Inflation GDP Deflator (mean)"
label var unemployment_ilo_est "Unemployment ILO Estimate (mean)"
label var unemployment_nat_est "Unemployment National Estimate (mean)"
label var capinnonresident "Capital Inflow Restrictions (mean)"
label var capoutresident "Capital Outflow Restrictions (mean)"
label var cap100 "Capital Account (mean)"
label var cur100 "Financial Current Account (mean)"
label var polity2 "Polity 2 (mean)"
label var polcomp "Political Competition (mean)"
label var resource_rents "Resource Rents"
label var mean_polity_g "Polity score (mean)"
label var mean_polcomp_g "Political Competition score (mean)"
label var exconst "Executive Constraints"
label var h_polcon3 "Political Constraints Index III"
label var fh_civ "Civil Liberties Rating (Freedom House)"
label var fh_pol "Political Rights Rating"
label var execrlc "Chief Executive Party Orientation"
label var pr "Proportional Representation"
label var worker "Worker Rights"
label var lvau "De Jure and De Facto Central Bank Independence Index unweighted"
label var lvaw "De Jure and De Facto Central Bank Independence Index weighted"
label var age_dependency_ratio "Age Dependency Ratio"
label var underval_sd "Standard Deviation Exchange Rate Undervaluation"
label var lgrow9_sd "Standard Deviation Log Growth"
label var index "Country group index"
label var polcomp_dummy "Political Competition (Dummy)"
label var polity2_4 "Polity2_4"
label var polity2_3 "Polity 2_3"
label var banking_center "Banking Center"
label var euro "Monetary Union"
label var EU "European Union membership"
label var ifscode "International Financial Statistics Database Country Code"
label var exchangerateregime_fine "Exchange Rate Regime Rheinart and Rogoff (Fine classification)"
label var exchangerateregime_coarse "Exchange Rate Regime (Coarse Classification)"
label var base "ifs code of base country"
label var range "Range of Exchange Rate Against Base (in percent)"
label var numzero "Months with zero change in exchange rate"
label var pegtype "Peg Type 1 = 0% change, 2 = 1% band, 3 = 2% band, 4 = 1 time deval/reval (Shambaugh)"
// label var peg "Standard Shambaugh 2004 classification (1= peg,0= nonpeg) (Shambaugh)"
label var peg "20221019 DQJK updated Shambaugh peg"
label var sypeg "Single Year Peg (Shambaugh)"
label var sypeg "Shambaugh Updated single year peg"
label var spegtype "Single Year Peg Type (same rules as pegtype) (Shambaugh)"
label var maxde "Largest (or most positive) % monthly change vs base (Shambaugh)"
label var minde "Smallest (or most negative) % monthly change vs base (Shambaugh)"
label var softpeg "Soft Peg Classification from OST AEJ-macro 2010 (Shambaugh)"
label var softpegtype "Soft Peg Type (Shambaugh)"
label var evol "Standard Deviation of Percentage Change in the Exchange Rate (Shambaugh)"
label var kspeg "Klein Shambaugh Classification (peg+sypeg - type 4) see JIE 2008"
label var oecd "OECD"
label var euro "20221019 DQJK updated euro"
label var peg_no_euro "pegnoeuro=1 if (peg==1 & euro==0) - 20221019 DQJK updated"


save "C:\Users\junok\Dropbox\juno\five year files\QSW_Undervaluation_Models_2022Nov23.dta" , replace

********************************************************************************

**# Bookmark #4

xtset index year, delta(5)

eststo clear
**********                        Polity2                             **********

**********              3. Polity2 IV 		  **********
eststo: xi: ivreg2 d.underval91 i.year l.underval91 l.peg l.lnrealgdp9 l.lgrow9 l.balance9 l.ltrade9 l.inflation  age (l.polity2= l.mean_polity_g l2.mean_polity_g l3.mean_polity_g) , first cluster(index) savefirst savefprefix(f1)



**********                        Polcomp                             **********

**********              6. Polcomp IV 		  **********

eststo: xi: ivreg2 d.underval91 i.year l.underval91 l.peg l.lnrealgdp9 l.lgrow9 l.balance9 l.ltrade9 l.inflation age (l.polcomp= l.mean_polcomp_g l2.mean_polcomp_g l3.mean_polcomp_g) , first cluster(index) savefirst savefprefix(f2)



esttab * using Table_A12.csv , replace label  compress b(%9.3f) se(3) starlevels(* 0.10 ** 0.05 *** 0.01) sca(N N_clust r2_w r2_o) sfmt(%9.0f %9.0f %9.3f ) nomtitles  nonotes noobs 



